package org.abratuhi.kvngroupware.model;

public class KVNGroupwareClientConsole {
	
	/*String[] parseCommand(String command){
		return command.split(kvnclient.locale.getProperty("console.separator"));
	}
	
	public void proceedCommand(String command){
		String[] params = parseCommand(command);
		//System.out.println("Console: proceeding command["+command+"] = ["+params[0]+" "+params[1]+" "+params[2]+"]"); // TODO -> logger
		proceedCommand(params);
	}
	public void proceedCommand(String[] params){
		if(params[1].equals("chatroom")){
			proceedChatroomCommand(params);
		}
		else if(params[1].equals("brainstorm")){
			proceedBrainstormCommand(params);
		}
		else if(params[1].equals("scenario")){
			proceedScenarioCommand(params);
		}
	}
	
	void proceedBrainstormCommand(String[] params){
		String cmd = params[0];
		String bid = params[2];
		if(cmd.equals("create")){
			String[] attrNames = new String[]{"type", "action", "brainstormId", "userId", "teamId", "brainstormTheme"};
			String[] attrValues= new String[]{"brainstorm", "create", 
					kvnclient.getUser().getId()+new Date().getTime(), 
					kvnclient.getUser().getId(), 
					kvnclient.getTeam().getId(), 
					bid};
			String text = new String();
			Element[] content = new Element[0];

			Message message = kvnclient.createMessage(attrNames, attrValues, text, content);
			kvnclient.sendMessage(message);
		}
		else if(cmd.equals("join")){
			String[] attrNames = new String[]{"type", "action", "brainstormId", "userId", "teamId", "brainstormTheme"};
			String[] attrValues= new String[]{"brainstorm", "join", bid, kvnclient.getUser().getId(), kvnclient.getTeam().getId(), kvnclient.getBrainstorm(bid).getTheme()};
			String text = new String();
			Element[] content = new Element[0];

			Message message = kvnclient.createMessage(attrNames, attrValues, text, content);
			kvnclient.sendMessage(message);
		}
		else if(cmd.equals("delete")){
			String[] attrNames = new String[]{"type", "action", "brainstormId", "userId", "teamId", "brainstormTheme"};
			String[] attrValues= new String[]{"brainstorm", "delete", bid, kvnclient.getUser().getId(), kvnclient.getTeam().getId(), kvnclient.getBrainstorm(bid).getTheme()};
			String text = new String();
			Element[] content = new Element[0];

			Message message = kvnclient.createMessage(attrNames, attrValues, text, content);
			kvnclient.sendMessage(message);
		}
	}
	
	void proceedChatroomCommand(String[] params){
		String cmd = params[0];
		String cid = params[2];
		if(cmd.equals("create")){
			String[] attrNames = new String[]{"type", "action", "chatroomId", "chatroomTheme", "userId"};
			String[] attrValues= new String[]{"chatroom", "create", kvnclient.getUser().getId()+String.valueOf(new Date().getTime()), cid, kvnclient.getUser().getId()};
			String text = new String();
			Element[] content = new Element[0];
			
			Message message = kvnclient.createMessage(attrNames, attrValues, text, content);
			kvnclient.sendMessage(message);
		}
		else if(cmd.equals("join")){
			String[] attrNames = new String[]{"type", "action", "chatroomId", "chatroomTheme", "userId"};
			String[] attrValues= new String[]{"chatroom", "join", cid, kvnclient.getChatroom(cid).getTheme(), kvnclient.getUser().getId()};
			String text = new String();
			Element[] content = new Element[0];
			
			Message message = kvnclient.createMessage(attrNames, attrValues, text, content);
			kvnclient.sendMessage(message);
		}
		else if(cmd.equals("delete")){
			String[] attrNames = new String[]{"type", "action", "chatroomId", "chatroomTheme", "userId"};
			String[] attrValues= new String[]{"chatroom", "delete", cid, kvnclient.getChatroom(cid).getTheme(), kvnclient.getUser().getId()};
			String text = new String();
			Element[] content = new Element[0];
			
			Message message = kvnclient.createMessage(attrNames, attrValues, text, content);
			kvnclient.sendMessage(message);
		}
	}
	
	void proceedScenarioCommand(String[] params){
		String cmd = params[0];
		String cid = params[2];
		if(cmd.equals("create")){
			Scenario sc = new Scenario(kvnclient.getUser().getTeamId(), cid);
			String[] attrNames = new String[]{"type", "action", "userId", "teamId", "scenarioId"};
			String[] attrValues= new String[]{"scenario", "create", kvnclient.getUser().getId(), kvnclient.getTeam().getId(), sc.getId()};
			String text = new String();
			Element[] content = new Element[]{sc.toElement()};
			
			Message message_create = kvnclient.createMessage(attrNames, attrValues, text, content);
			kvnclient.sendMessage(message_create);
		}
		else if(cmd.equals("join")){
			String[] attrNames = new String[]{"type", "action", "userId", "teamId", "scenarioId"};
			String[] attrValues= new String[]{"scenario", "join", kvnclient.getUser().getId(), kvnclient.getTeam().getId(), cid};
			String text = new String();
			Element[] content = new Element[0];
			
			Message message_edit = kvnclient.createMessage(attrNames, attrValues, text, content);
			kvnclient.sendMessage(message_edit);
		}
		else if(cmd.equals("delete")){
			String[] attrNames = new String[]{"type", "action", "userId", "teamId", "scenarioId"};
			String[] attrValues= new String[]{"scenario", "delete", kvnclient.getUser().getId(), kvnclient.getTeam().getId(), cid};
			String text = new String();
			Element[] content = new Element[0];
			
			Message message_delete = kvnclient.createMessage(attrNames, attrValues, text, content);
			kvnclient.sendMessage(message_delete);
		}
	}*/
}
